class Solution:
    def superPow(self, a: int, b) -> int:
        c = 1337
        r = 1
        while len(b)>0:
            d = b.pop(-1)
            for i in range(d):
                r = (r*a)%c
            d = 9
            a1 = a
            for i in range(d):
                a = (a1*a)%c
        return r%c




if __name__ == '__main__':
    so = Solution()
    a = 2
    b = [1,1]
    r = so.superPow(a,b)
    print(r)
